package com.jinkaimen.goodcash.ui.activity;

import android.os.Message;

import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.ChannelUtils;
import com.ht.baselibs.utils.SharedPreferencesUtils;
import com.jinkaimen.goodcash.R;
import com.jinkaimen.goodcash.constant.ConstantPool;
import com.umeng.analytics.MobclickAgent;


public class SplashActivity extends BaseActivity {

    public static final int MSG_WHAT_LAUNCHER_TIME_UP = 0;

    //是否是第一次打开
    public static final String IS_FIRST_OPEN = "is_first_open_v0";
    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected boolean isFulleScreen() {
        return true;
    }

    @Override
    protected void initChannel() {
        MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, "586c9a9e6e27a428320011de", ChannelUtils.getChannel()));
    }

    @Override
    protected void initTitleBar() {

    }

    @Override
    protected int initContentView() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initChildView() {

    }

    @Override
    protected void initChildData() {
        //这里做2秒的延时操作
        Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                Message msg = new Message();
                msg.what = MSG_WHAT_LAUNCHER_TIME_UP;
                mHandler.sendMessage(msg);
            }
        });
        thread.start();
    }

    @Override
    protected void setChildViewListener() {

    }

    @Override
    protected void handleMessage(BaseActivity context, Message msg) {
        switch (msg.what){
            case MSG_WHAT_LAUNCHER_TIME_UP:

                long uid = SharedPreferencesUtils.getLong(ConstantPool.REPORT_ACCOUT_ID, 0);
                if (uid == 0){
                    ActivityUtils.startActivityAndFinishByAlpha(this, LoginActivity.class);
                } else {
                    ActivityUtils.startActivityAndFinishByAlpha(this, ReportMainActivity.class);
                }

                break;
        }
    }
}
